from django.conf.urls import url
from . import views
from rest_framework.routers import DefaultRouter
#第一种实现方式
# urlpatterns = [
#     # 查询所有省
#     url(r'areas/$', views.AreaListView.as_view()),
#     url(r'areas/(?P<pk>\d+)', views.AreaDetailView.as_view()),
# ]

"""第二种实现方式"""
urlpatterns = []
router = DefaultRouter()
router.register(r'areas', views.AreasViewSet, basename='areas')#如果视图中没有制定queryset，就必须给basename传参，如果不传默认取queryset中指定查询集模型名小写作为路由器别名
urlpatterns += router.urls